package com.example.test.chapter7.listviewoneicon;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.example.test.R;

public class ListViewStaticActivity extends Activity implements
		OnItemClickListener {
	private TextView textView;
	private String[] SmartPhones = new String[] { "HTC Rezound",
			"Samsung Galaxy S II Skyrocket", "Samsung Galaxy Nexus",
			"Motorola Droid Razr", "Samsung Galaxy S", "Samsung Epic Touch 4G",
			"iPhone 4S", "HTC Titan" };

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.list_view_one_icon);
		ListView listView = (ListView) findViewById(R.id.list_view_one_icon);
		listView.setAdapter(new ArrayAdapter<String>(this, R.layout.row,
				R.id.label_list_view_one_icon, SmartPhones));
		listView.setOnItemClickListener(this);
		textView = (TextView) findViewById(R.id.selected_list_view_one_icon);
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		textView.setText(SmartPhones[arg2]);
	}

}
